{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd><form method="get"><input type="text" class="input" placeholder="请输入您需要搜索的品牌名字！" name="search"><input type="submit" value="搜索" class="button" /></form></dd>
			</dl>
		</div>
		<div class="nav1">
			<ul>
				<a href="/admin/brand/index"><li {{if eq .cid ""}}class="no"{{end}}>全部功能</li></a>
				{{range .column}}
				<a href="/admin/brand/index?cid={{.id}}" {{if eq $.cid .id}}class="no"{{end}}><li>{{.name}}</li></a>
				{{end}}
			</ul>
		</div>
		<div class="content">
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>{{.title}}说明</b><br>
						<p>品牌是平台所经营产品的品牌,所属类目选择之后,页面之中对应的栏目中会出现对应的品牌供用户筛选</p>
					</dt>
					<dd><a href="/admin/brand/add"><button type="button" class="button">添加品牌</button></a></dd>
				</dl>
			</div>
			<table class="table">
				<thead><th width="10%">logo</th><th width="35%">品牌信息</th><th width="25%">其他信息</th><th width="10%">权限</th><th width="10%">操作</th></thead>
				{{range .info}}
				<tr id="{{.id}}">
					<td class="center"><img src="{{.pathname}}" class="img"></td>
					<td>
						品牌名称：{{.name}}（<!-- <img src="../static/all/ensign-1.png" class="ensign"> --> ID：{{.id}} ）<br>
						<!-- 所属店铺：{{if ne .gid "0"}}<a href="/admin/shop/content?id={{.gid}}" class="tz">{{.gname}}</a>{{else}}主平台{{end}}
						（GID：{{.gid}} ）<br> -->
						<b>所属栏目：</b><mark>{{range .lm}}{{.name}}、{{end}}</mark><br>
						<p>{{.intr}}</p>
					</td>
					<td>
						排序：{{.sort}}<br>
						点击：{{.click}}<br>
						添加时间：{{.addtime}}<br>
						修改时间：{{.modifytime}}
					</td>
					<td class="operation">
						<a class="change" data-id="{{.id}}" data-status="censoring">{{if eq .censoring "1"}}已审核{{else}}未审核{{end}}</a><br>
						<a class="change" data-id="{{.id}}" data-status="recommend">{{if eq .recommend "1"}}已推荐{{else}}未推荐{{end}}</a><br>
						<a class="change" data-id="{{.id}}" data-status="is_show">{{if eq .is_show "1"}}已显示{{else}}已隐藏{{end}}</a>
					</td>
					<td class="operation">
						<a href="/admin/brand/edit?id={{.id}}">编辑</a><br>
						<a href="/admin/brand/content?id={{.id}}">详情</a><br>
						<a class="del" data-id="{{.id}}">删除</a><br>
						<a href="/admin/product/index?bid={{.id}}">品牌产品</a><br>
						<a href="javascript: void 0" class="proExport" data-id="{{.id}}" target="_blank">导出产品</a>
					</td>
				</tr>
				{{end}}
				{{if ne .paginator.totalpages 1}}
					<tr>
						<td  colspan="5">
							<div class="paging">
								{{if ne .paginator.currpage 1}}
								<a href="{{$.url}}page={{.paginator.firstpage}}">首页</a>
								<a href="{{$.url}}page={{.paginator.prevpage}}">&lt;&lt;</a>
								{{else}}
								<a class="disable">首页</a>
								<a class="disable">&lt;&lt;</a>
								{{end}}
								{{range $index,$page := .paginator.pages}}
								{{if eq $.paginator.currpage $page}} 
								<a class="no">{{$page}}</a>
								{{else}}
								<a href="{{$.url}}page={{$page}}">{{$page}}</a>
								{{end}}
								{{end}}
								{{if eq .paginator.currpage .paginator.totalpages}}
								<a class="disable">&gt;&gt;</a>
								<a class="disable">尾页</a>
								{{else}}
								<a href="{{$.url}}page={{.paginator.nextpage}}">&gt;&gt;</a>
								<a href="{{$.url}}page={{.paginator.totalpages}}">尾页</a>
								{{end}}
							</div>
						</td>
					</tr>
				{{end}}
			</table>


		</div>
	</article>
</section>

<footer><!-- 系统监控内容 --></footer>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
    $('.del').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要删除这条数据吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:'mt_brand',id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('删除成功');
						$('#'+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.change').click(function(){
		var id=$(this).attr('data-id');
		var status=$(this).attr('data-status');
		var that=$(this)
		// wxc.xcConfirm("您确定要删除这条数据吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/change',
				data:{table:'mt_brand',id:id,status:status},
				type:'get',
				success:function(res) {
					if(res.status==1){
						that.html(res.info)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		// }});
	})
	$('.proExport').click(function () {
		var id = $(this).attr('data-id')
		var timer = null
		var once = 0
		$('.animated').show()
		$('body').toast({
	        position:'fixed',
	        animateIn:'fadeIn',
	        animateOut:'fadeOut',
	        content:'导出中...',
	        duration:'99999999',
	        isCenter:true,
	    });
		function fetch() {
			$.ajax({
				url: '/admin/getproduct',
				data: {bid: id, once: once},
				timeout: 1000,
				success: function (res) {
					if (res.status == 1) {
						clearInterval(timer)
						$('.animated').hide()
						window.location = res.pathname
					} else if (res.status == 0) {
						clearInterval(timer)
						$('.animated').hide()
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})
		}
		fetch()
		once = 1
		timer = setInterval(fetch, 1000)
	})
</script>
</body>
</html>
